import { log } from "console";

let a:string = '234'
let str:string = `dddd${a}`

console.log(str);

let strb:String =  new String("sdfdsf")
let notANumber2 = NaN;//Nan

if (isNaN(notANumber2)) {
    console.log('是nan');
   
}

// 数字类型
let notANumber: number = NaN;//Nan
let num: number = 123;//普通数字
let infinityNumber: number = Infinity;//无穷大
let decimal: number = 6;//十进制
let hex: number = 0xf00d;//十六进制
let binary: number = 0b1010;//二进制
let octal: number = 0o744;//八进制s

let booleand: boolean = true //可以直接使用布尔值
 
let booleand2: boolean =  Boolean(1) //也可以通过函数返回布尔值

let booleand3: Boolean =  new Boolean() //也可以通过函数返回布尔值


// 数组


let arr1:number[] = [234,23,423,4,234,2]

let arr2:string[] = ['23432']


let arr3:Array<number> = [234,23,423,4,234,2]

let arr4:Array<string> = ['3432','234234']


let data:number[][] = [[1,2], [3,4]];
let data2:Array<Array<number>> = [[1,2], [3,4]];
let data23:Array<number[]> = [[1,2], [3,4]];


function Arr(...args:any): void {
  console.log(arguments)
  //错误的arguments 是类数组不能这样定义
  let arr:any = arguments

  console.log(arr);
  
}
Arr(111, 222, 333)


// 元组 Tuple  
// 1.元组类型允许表示一个已知元素数量和类型的数组
// 2.各元素的类型不必相同。
// 3.元组赋值要遵循类型顺序

let tuple1:[number,string] = [23424,'234324']



let arr:[number,string] = [1,'string']
// arr.push('234234')//error

// arr[3] = 'sdfsf'

console.log(arr);


let excelData:[string,string,number,boolean][] = [
  ['zhichao','nan',20,true],
  ['zhichao1','nv',21,true],
  ['zhichao2','weizhi',20,true],
  ['zhichao3','nv',20,true],
]

let excelData2 :Array<[string,string,number,boolean]> = [
  ['zhichao','nan',20,true],
  ['zhichao1','nv',21,true],
  ['zhichao2','weizhi',20,true],
  ['zhichao3','nv',20,true],
]


// JavaScript 没有空值（Void）的概念，在 TypeScript 中，可以用 void 表示没有任何返回值的函数
let fun12 = function ():void {
  console.log('我没有返回值');

  // return 223 //不能将类型“number”分配给类型“void”。ts(2322
  
}

let u:undefined | string


let nl:null = null
console.log(u);


let intervalId: NodeJS.Timeout

 intervalId = setInterval(() => {
  
}, 200);

clearInterval(intervalId)


function fun22(params?:string | undefined):string {
  return `我叫：${params || '无名'}`
}


let fstr:string = fun22('志超')
console.log(fstr);
let fstr2:string = fun22()


//这样是没问题的
let test1: null = null
let num21: string = "1"
 
// num21 = test1

// test1 = num21
 
//或者这样的
let test3: undefined = undefined
let num23: string = "1"
 
// num23 = test3

// test3 = num23


// let n:void = null //TS2322: Type 'null' is not assignable to type 'void'.

console.log('-------------------');

function Arr2(...args:any): void {
  console.log(arguments)
  //错误的arguments 是类数组不能这样定义
  let arr23333:IArguments = arguments
}
Arr(111, 222, 333)


//其中 IArguments 是 TypeScript 中定义好了的类型，它实际上就是：
// interface IArguments {
//   [index: number]: any;
//   length: number;
//   callee: Function;
//   }



//在这个例子当中我们看到接口中并没有定义C但是并没有报错
//应为我们定义了[propName: string]: any;
//允许添加新的任意属性
interface Person {
  [propName: string]: any;
}

const person:Person  = {
  a:"213",
  c:"123",
  u:'uuu'
}



interface IMyArray {
  [propName: number]: any; // 可以任意添加数组元素和对象属性
  length:number
}


let arrrrr:IMyArray = [23423,'23424','23424',true,{name:'zhichao'}]
arrrrr.length

// interface NumberArray {
//   [index: number]: number;
// }
// // let fibonacci: NumberArray = [1, 1, 2, 3, 5];
//表示：只要索引的类型是数字时，那么值的类型必须是数字。
